package main

import (
	"fmt"
	"sort"
)

type student struct {
    id   int
    name string
    age  int
}

//人
type Person struct {
    name string
    sex  string
    age  int
}

// 学生
type Student struct {
    *Person
    id   int
    addr string
}

func demo(ce []student) {
    //切片是引用传递，是可以改变值的
    ce[1].age = 999
    // ce = append(ce, student{3, "xiaowang", 56})
    // return ce
}
func main() {
    // var ce []student  //定义一个切片类型的结构体
    ce := []student{
        {1, "xiaoming", 22},
        {2, "xiaozhang", 33},
    }
    fmt.Println(ce)
    demo(ce)
    fmt.Println(ce)

	ce1 := make(map[int]student)
    ce1[1] = student{1, "xiaolizi", 22}
    ce1[2] = student{2, "wang", 23}
    fmt.Println(ce1)
    delete(ce1, 2)
    fmt.Println(ce1)

	map1 := make(map[int]string, 5)
    map1[1] = "www.topgoer.com"
    map1[2] = "rpc.topgoer.com"
    map1[5] = "ceshi"
    map1[3] = "xiaohong"
    map1[4] = "xiaohuang"
    sli := []int{}
    for k:= range map1 {
        sli = append(sli, k)
    }
    sort.Ints(sli)
    for i := 0; i < len(map1); i++ {
        fmt.Println(map1[sli[i]])
    }

	s1 := Student{&Person{"5lmh", "man", 18}, 1, "bj"}
    fmt.Println(s1)
    fmt.Println(s1.name)
    fmt.Println(s1.Person.name)
}